<?php


namespace App\Admin\Forms\Config;


use Illuminate\Support\Arr;

class AppConfig extends ConfigForm
{
    public static function label() :array
    {
        return [
            "name"=>"应用名称",
            "url"=>"网站地址",
            "asset_url"=>"资源地址",
            "timezone"=>"时区设置",
            "debug"=>"开启调试",
            "locale"=>"语言",
            "debug_bar" => "调试栏",
            "logo"  =>"LOGO",
        ];
    }


    public static function mapping() :array
    {
        return [
            "name" => "app.name",
            "url" => "app.url",
            "asset_url" => "app.asset_url",
            "timezone" => "app.timezone",
            "debug" => "app.debug",
            "locale" => "app.locale",
            "debug_bar" => "debugbar.enabled",
            "logo"  =>"app.logo",
        ];
    }

    public function form()
    {
        $this->width(4);
        $label = static::label();
        $this->text('name',Arr::get($label,"name"))->required();
        $this->url('url',Arr::get($label,"url"))->required();
        $this->url('asset_url',Arr::get($label,"asset_url"));
        $this->radio('timezone', Arr::get($label,"timezone"))->required()->options(['PRC' => 'PRC', 'UTC' => 'UTC']);
        $this->radio('debug', Arr::get($label,"debug"))->required()->options(['0' => '关闭', '1' => '开启'])->default(0);
        $this->radio('debug_bar', Arr::get($label,"debug_bar"))->required()->options(['0' => '关闭', '1' => '开启'])->default(1);
        $this->radio('locale', Arr::get($label,"locale"))->required()->options(['en' => 'English', 'zh_CN' => '简体中文'])->default("en");
        $this->image("logo",Arr::get($label,"logo"))->autoUpload()->required();
    }
}
